package frontend.pages.base;

import java.io.Serializable;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;

import frontend.core.PrometeicaWebSession;
import frontend.pages.HomePage;
import frontend.pages.utils.UtilsPage;

@AuthorizeInstantiation("USER")
public abstract class BaseWebPage extends WebPage {

	public BaseWebPage() {
		initPage();
	}

	private void initPage() {
		Serializable loginUser = PrometeicaWebSession.get().getAttribute(
				PrometeicaWebSession.LOGIN_FULL_NAME_ATTR);
		add(new Label("loginUser", "" + loginUser));
		add(new Link<String>("signoutLink") {
			@Override
			public void onClick() {
				PrometeicaWebSession.get().invalidate();

			}
		});

		WebMarkupContainer homeContainer = new WebMarkupContainer(
				"homeContainer");
		homeContainer.add(new BookmarkablePageLink("homeLink", HomePage.class));
		add(homeContainer);
		
		WebMarkupContainer utilsLinkContainer = new WebMarkupContainer(
				"utilsContainer");
		utilsLinkContainer.add(new BookmarkablePageLink("utilsLink",
				UtilsPage.class));
		add(utilsLinkContainer);

		WebMarkupContainer familyLinkContainer = new WebMarkupContainer(
				"familyContainer");
		familyLinkContainer.add(new BookmarkablePageLink("familyLink",
				UtilsPage.class));
		add(familyLinkContainer);

	}

}
